import 'package:json_annotation/json_annotation.dart';

part 'todo.model.g.dart';

List<TodoModel> getTodoModelList(List<dynamic> list) {
  List<TodoModel> result = [];
  list.forEach((item) {
    result.add(TodoModel.fromJson(item));
  });
  return result;
}

@JsonSerializable()
class TodoModel extends Object {
  @JsonKey(name: '_id')
  String id;

  @JsonKey(name: 'complete')
  bool complete;

  @JsonKey(name: 'todo')
  String todo;

  TodoModel(
    this.id,
    this.complete,
    this.todo,
  );

  factory TodoModel.fromJson(Map<String, dynamic> srcJson) =>
      _$TodoModelFromJson(srcJson);

  Map<String, dynamic> toJson() => _$TodoModelToJson(this);
}
